﻿<!doctype html>
 <html lang="zh-CN">
 <head>
   <meta charset="UTF-8">
   <link rel="stylesheet" href="${req.contextPath}/css/common.css">
   <link rel="stylesheet" href="${req.contextPath}/css/main.css">
   <script type="text/javascript" src="${req.contextPath}/js/jquery.min.js"></script>
   <script type="text/javascript" src="${req.contextPath}/js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="${req.contextPath}/js/common.js"></script>

</head>
<body>
        <div  class="box_bottom pb5 pt5 pr10" style="border-top:1px solid #dadada;">
              <div class="search_bar_btn" style="text-align:left;" >
                  <a href="${req.contextPath}/administrative/ReserveMeetLog" class="ext_btn"><span class=""></span>会议室预定记录</a>
                 <a href="${req.contextPath}/administrative/ReserveMeet-ui" class="ext_btn"><span class=""></span>会议室预定</a>
              </div>
            </div>

        <#if user.roleId==7>
             <div  class="box_bottom pb5 pt5 pr10" style="border-top:1px solid #dadada;">
              <div class="search_bar_btn" style="text-align:center;" >
                 <a href="${req.contextPath}/administrative/saveMeet-ui" class="ext_btn"><span class="add"></span>添加会议室</a>
              </div>
            </div>
        </#if>
			
		
 <div id="table" class="mt10">
        <div class="box span10 oh">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                    <th> <input type="checkbox" id="checkall" onclick="checkAll()"></th>
                   <th >会议室名称</th>
                   <th >会议室描述</th>
                    <#if user.roleId==7>
				   <th>操作</th>
                    </#if>
                    </tr>
                <#list pageInfo.list as list>
                <tr class="tr" align="center">
                    <td class="td_center" name='id'><input type="checkbox" name='id' value="${list.meetId}" onclick="docheck()" /></td>
                   <td>${list.meetName}</td>
                   <td>${list.meetDesc}</td>
                    <#if user.roleId==7>
				   <td>
					  <a href="${req.contextPath}/administrative/updateMeet-ui?id=${list.meetId}&page=${pageInfo.getPageNum()}">编辑</a> |&nbsp;
					  <a href="javascript:void(0)" onclick="del(${list.meetId})">删除</a>
				   </td>
				   </#if>
                 </tr>
                </#list>

                  <tr>
                      <td colspan="2">
                          <#if user.roleId==7>
                              <input type="button" class="btn btn82 btn_del" value="删除" onclick="delAll()">
                          </#if>
                          <input type="button" name="button"  class="btn btn82 btn_export" value="导出" onclick="excel()">
                      </td>
                      <td colspan="5" align="right">
                          <div class="page mt10">
                              <div class="pagination">
                                  <ul >
                                      <li class="first-child"><a href="${req.contextPath}/resource/xingzheng/demo1/list">首页</a></li>
                                      <#if pageInfo.getPrePage() lt 1>
                                          <li>
                                              <a href="${req.contextPath}/resource/xingzheng/demo1/list?page=1">上一页</a>
                                          </li>
                                      <#else >
                                          <li>
                                              <a href="${req.contextPath}/resource/xingzheng/demo1/list?page=${pageInfo.getPrePage()}">上一页</a>
                                          </li>
                                      </#if>

                                      <#if pageInfo.getNextPage() == 0>
                                          <li>
                                              <a href="${req.contextPath}/resource/xingzheng/demo1/list?page=${pageInfo.getPages()}">下一页</a>
                                          </li>
                                      <#else >
                                          <li>
                                              <a href="${req.contextPath}/resource/xingzheng/demo1/list?page=${pageInfo.getNextPage()}">下一页</a>
                                          </li>
                                      </#if>
                                      <li ><a href="${req.contextPath}/resource/xingzheng/demo1/list?page=${pageInfo.getPages()}">末页</a></li>
                                      <li ><span>共${pageInfo.total}条数据</span></li>
                                      <li ><span>共${pageInfo.getPages()}页</span></li>
                                  </ul>
                              </div>
                          </div>
                      </td>
                  </tr>
            </table>
        </div>
     </div>

</body>
 <script type="text/javascript" src="${req.contextPath}/js/jquery.min.js"></script>
 <script>

     var checkall, item;
     checkall = document.getElementById("checkall");
     item = document.getElementsByName("id");
     //全选框判断：全选 全不选
     function checkAll() {
         for (var i = 0; i <item.length; i++) {
             if(checkall.checked){
                 item[i].checked = true;
             }else{
                 item[i].checked = false;
             }
         }
     }
     //单选框判断:如果单选框被选中的数量和单选框的数量相等的时候全选框选中，反之没有被选中；
     function docheck(){
         var count=0;
         for (var i = 0; i <item.length ; i++) {
             if(item[i].checked){
                 count++;
             }
         }
         if(count===item.length){
             checkall.checked = true;
         }else{
             checkall.checked = false;
         }
     }

     //批量删除
     function delAll() {
         var chk_value =[];//定义一个数组
         $('input[name="id"]:checked').each(function(){//遍历每一个名字为id的复选框，其中选中的执行函数
             chk_value.push($(this).val());//将选中的值添加到数组chk_value中
         });
         if (chk_value.length==0){
             alert("请先选择要删除的数据");
             return;
         }
         $.post(
             "${req.contextPath}/administrative/delAllMeet",
             {ids:chk_value},
             function (result) {
                 if (result.code == 0) {
                     alert("删除成功");
                     location.href = "${req.contextPath}/resource/xingzheng/demo1/list";
                 } else {
                     alert(result.msg)
                 }
             },
             "json"
         );
     }

     //导出
     function excel() {
         var chk_value =[];//定义一个数组
         $('input[name="id"]:checked').each(function(){//遍历每一个名字为id的复选框，其中选中的执行函数
             chk_value.push($(this).val());//将选中的值添加到数组chk_value中
         });
         if (chk_value.length==0){
             alert("请先选择要导出的数据");
             return;
         }
         location.href="${req.contextPath}/administrative/excelMeet?ids="+chk_value;
     }


     //单个删除
     function del(id) {
         if (confirm("确定要删除这条信息吗")) {
             $.post(
                 "${req.contextPath}/administrative/delMeet?id=" + id,
                 null,
                 function (result) {
                     if (result.code == 0) {
                         alert("删除成功");
                         location.href = "${req.contextPath}/resource/xingzheng/demo1/list";
                     } else {
                         alert(result.msg)
                     }
                 },
                 "json"
             );
         }
     }


 </script>
</html>